package com.xhd.db;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.math.BigDecimal;
import java.sql.CallableStatement;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Collection;
import java.util.Hashtable;
import java.util.List;
import java.util.Vector;

import com.xhd.base.log.Log;
import com.xhd.base.log.LogFactory;
import com.xhd.base.util.Date;
import com.xhd.exception.DatabaseException;
import com.xhd.server.ServerConfig;

public class DBControl
{
  private DBConfig jm53;
  private long jm241 = 0L;
  private boolean jm242 = true;
  private DBConn jm243 = null;
  private String jm244 = null;
  private int jm245;
  private boolean jm246 = false;
  private int jm247 = 0;
  private final int jm248 = -1111;
  private static final Log jm249;
  static Class jm10;

  static
  {
    Class tmp3_0 = jm10;
    if (tmp3_0 == null)
    {
     
      try
      {
     DBControl.jm10 = Class.forName("com.sinocc.systemdbmanager.DBControl");
      }
      catch (ClassNotFoundException localClassNotFoundException)
      {
        throw new NoClassDefFoundError(localClassNotFoundException.getMessage());
      }
    }
    jm249 = LogFactory.getLog(tmp3_0);
  }

  public DBControl(DBConfig paramDBConfig)
  {
    this.jm53 = paramDBConfig;
    this.jm247 = paramDBConfig.getDBType();
    if ((paramDBConfig.getLanguage() == null) || (paramDBConfig.getLanguage().length() <= 0))
      return;
    this.jm246 = true;
  }

  protected void setConfig(DBConfig paramDBConfig)
  {
    this.jm53 = paramDBConfig;
    this.jm247 = paramDBConfig.getDBType();
    if ((paramDBConfig.getLanguage() == null) || (paramDBConfig.getLanguage().length() <= 0))
      return;
    this.jm246 = true;
  }

  public DBConfig getConfig()
  {
    return this.jm53;
  }

  protected void log(String paramString, long paramLong)
  {
    long l = 0L;
    if (paramLong > 0L)
    {
      l = System.currentTimeMillis() - paramLong;
      this.jm241 += l;
    }
    jm249.sql(getId(), paramString, l);
  }

  protected long getTotalTime()
  {
    return this.jm241;
  }

  protected void setIsLogCost(boolean paramBoolean)
  {
    this.jm242 = paramBoolean;
  }

  protected String getId()
  {
    if (this.jm243 != null)
      return this.jm243.getId();
    return this.jm53.getId();
  }

  public String getLastSQL()
  {
    return this.jm244;
  }

  public int getCount()
  {
    return this.jm245;
  }

  public DBConn getConn()
    throws DatabaseException
  {
    if (this.jm243 == null)
    {
      if (this.jm53.isPause())
        throw new DatabaseException(30088, this.jm53.getName());
      try
      {
        if (this.jm53.hasPool())
        {
          DBPool localDBPool = null;
          localDBPool = XDBManager.getInstance().getPool(this.jm53);
          this.jm243 = localDBPool.getConnection();
         
        }
        this.jm243 = XDBManager.getInstance().getNoPoolConnection(this.jm53);
      }
      catch (DatabaseException localDatabaseException)
      {
        throw localDatabaseException;
      }
      catch (Throwable localThrowable)
      {
        jm249.error(localThrowable);
        throw new DatabaseException(30051, this.jm53.getName());
      }
    }
    label119: return this.jm243;
  }

  protected String getValue(int paramInt1, ResultSet paramResultSet, int paramInt2)
  {
    try
    {
      String str = "";
      Object localObject1 = null;
      switch (paramInt1)
      {
      case -1:
      case 1:
      case 12:
        str = paramResultSet.getString(paramInt2);
        break;
      case -1111:
        byte[] arrayOfByte = paramResultSet.getBytes(paramInt2);
        if (arrayOfByte == null)
          str = "";
        else
          str = new String(arrayOfByte);
        break;
      case 2:
        localObject1 = paramResultSet.getObject(paramInt2);
        str = (localObject1 == null) ? "0" : ((BigDecimal)localObject1).toString();
        break;
      case 3:
        localObject1 = paramResultSet.getObject(paramInt2);
        str = (localObject1 == null) ? "0" : ((BigDecimal)localObject1).toString();
        break;
      case 4:
        str = String.valueOf(paramResultSet.getInt(paramInt2));
        break;
      case 5:
        str = String.valueOf(paramResultSet.getInt(paramInt2));
        break;
      case 6:
        str = String.valueOf(paramResultSet.getFloat(paramInt2));
        break;
      case 7:
        localObject1 = paramResultSet.getObject(paramInt2);
        str = (localObject1 == null) ? "0" : ((BigDecimal)localObject1).toString();
        break;
      case 8:
        str = String.valueOf(paramResultSet.getDouble(paramInt2));
        break;
      case 91:
      case 92:
      case 93:
        Object localObject2;
        if (1 == this.jm247)
        {
          localObject2 = paramResultSet.getTimestamp(paramInt2);
          if (localObject2 == null)
            str = "";
          else
            str = new Date(((java.util.Date)localObject2).getTime()).toText();
        }
        else
        {
          localObject2 = (java.util.Date)paramResultSet.getObject(paramInt2);
          if (localObject2 == null)
            str = "";
          else
            str = new Date(((java.util.Date)localObject2).getTime()).toText();
        }
        break;
      case -5:
        str = String.valueOf(paramResultSet.getInt(paramInt2));
        break;
      case -6:
        str = String.valueOf(paramResultSet.getInt(paramInt2));
        break;
      case -7:
        str = (paramResultSet.getBoolean(paramInt2)) ? "1" : "0";
        break;
      default:
        str = paramResultSet.getString(paramInt2);
      }
      return ((str == null) ? "" : str);
    }
    catch (Exception localException)
    {
    }
    return ((String)"");
  }

  private int[] jm239(ResultSetMetaData paramResultSetMetaData, int paramInt)
    throws SQLException
  {
    int[] arrayOfInt = new int[paramInt];
    ++paramInt;
    for (int i = 1; i < paramInt; ++i)
    {
      int j = paramResultSetMetaData.getColumnType(i);
      arrayOfInt[(i - 1)] = j;
      if ((!(this.jm246)) || ((j != 1) && (j != -1) && (j != 12)))
        continue;
      String str = paramResultSetMetaData.getColumnTypeName(i);
      int k = str.charAt(0);
      if ((k == 110) || (k == 78))
        continue;
      arrayOfInt[i] = -1111;
    }
    return arrayOfInt;
  }

  public Vector multiRowSelect(String paramString, int paramInt1, int paramInt2)
    throws DatabaseException
  {
    return query(paramString, paramInt2 * paramInt1, paramInt1);
  }

  protected Vector query(String paramString, int paramInt1, int paramInt2)
    throws DatabaseException
  {
    if ((paramString == null) || (paramString.length() < 1))
      return null;
    Vector localVector1 = new Vector();
    Statement localStatement = null;
    long l = (this.jm242) ? System.currentTimeMillis() : 0L;
    this.jm244 = paramString;
    try
    {
      localStatement = getConn().createStatement();
      ResultSet localResultSet = localStatement.executeQuery(paramString);
      ResultSetMetaData localResultSetMetaData = localResultSet.getMetaData();
      int i = localResultSetMetaData.getColumnCount();
      int j = ServerConfig.QueryLimit / i;
      String[] arrayOfString = new String[i];
      for (int k = 0; k < i; ++k)
        arrayOfString[k] = localResultSetMetaData.getColumnName(k + 1).toLowerCase();
      int[] arrayOfInt = jm239(localResultSetMetaData, i);
      if (paramInt1 > 0)
        for (int i1 = 0; i1 < paramInt1; ++i1)
        {
          if (localResultSet.next())
            continue;
          Vector localVector2 = localVector1;
          return localVector2;
        }
      Hashtable localHashtable;
      int i4;
      if (paramInt2 > 0)
      {
        int i2 = 0;
       
        do
        {
          localHashtable = new Hashtable();
          for (i4 = 0; i4 < i; ++i4)
            localHashtable.put(arrayOfString[i4], getValue(arrayOfInt[i4], localResultSet, i4 + 1));
          localVector1.add(localHashtable);
          if (i2 >= j)
            throw new DatabaseException(30002);
          ++i2;
         
            
        }
        while (localResultSet.next());
      }
      else
      {
        int i3 = 0;
        while (localResultSet.next())
        {
          localHashtable = new Hashtable();
          for (i4 = 0; i4 < i; ++i4)
            localHashtable.put(arrayOfString[i4], getValue(arrayOfInt[i4], localResultSet, i4 + 1));
          localVector1.add(localHashtable);
          if (++i3 <= j)
            continue;
          throw new DatabaseException(30002);
        }
      }
      label388: localResultSet.close();
    }
    catch (SQLException localSQLException1)
    {
      jm249.error(paramString, localSQLException1);
      throw new DatabaseException(30031, paramString, localSQLException1, getId());
    }
    finally
    {
      log(paramString, l);
      try
      {
        if (localStatement != null)
          localStatement.close();
      }
      catch (SQLException localSQLException2)
      {
        jm249.error(localSQLException2);
        throw new DatabaseException(30023);
      }
    }
    return localVector1;
  }

  public Vector multiRowSelect(DBSQL paramDBSQL, int paramInt1, int paramInt2)
    throws DatabaseException
  {
    return query(paramDBSQL, paramInt2 * paramInt1, paramInt1);
  }

  protected Vector query(DBSQL paramDBSQL, int paramInt1, int paramInt2)
    throws DatabaseException
  {
    if ((paramDBSQL == null) || (paramDBSQL.length() < 1))
      return null;
    Vector localVector1 = new Vector();
    PreparedStatement localPreparedStatement = null;
    long l = (this.jm242) ? System.currentTimeMillis() : 0L;
    this.jm244 = paramDBSQL.toString();
    try
    {
      localPreparedStatement = getConn().prepareStatement(paramDBSQL.getSQL());
      paramDBSQL.toPreparedStatement(localPreparedStatement);
      ResultSet localResultSet = localPreparedStatement.executeQuery();
      ResultSetMetaData localResultSetMetaData = localResultSet.getMetaData();
      int i = localResultSetMetaData.getColumnCount();
      int j = ServerConfig.QueryLimit / i;
      String[] arrayOfString = new String[i];
      for (int k = 0; k < i; ++k)
        arrayOfString[k] = localResultSetMetaData.getColumnName(k + 1).toLowerCase();
      int[] arrayOfInt = jm239(localResultSetMetaData, i);
      if (paramInt1 > 0)
        for (int i1 = 0; i1 < paramInt1; ++i1)
        {
          if (localResultSet.next())
            continue;
          Vector localVector2 = localVector1;
          return localVector2;
        }
      Hashtable localHashtable;
      int i4;
      if (paramInt2 > 0)
      {
        int i2 = 0;
     
        do
        {
          localHashtable = new Hashtable();
          for (i4 = 0; i4 < i; ++i4)
            localHashtable.put(arrayOfString[i4], getValue(arrayOfInt[i4], localResultSet, i4 + 1));
          localVector1.add(localHashtable);
          if (i2 >= j)
            throw new DatabaseException(30002);
          ++i2;
          
        }
        while (localResultSet.next());
      }
      else
      {
        int i3 = 0;
        while (localResultSet.next())
        {
          localHashtable = new Hashtable();
          for (i4 = 0; i4 < i; ++i4)
            localHashtable.put(arrayOfString[i4], getValue(arrayOfInt[i4], localResultSet, i4 + 1));
          localVector1.add(localHashtable);
          if (++i3 < j)
            continue;
          throw new DatabaseException(30002);
        }
      }
      label400: localResultSet.close();
    }
    catch (SQLException localSQLException1)
    {
      jm249.error(this.jm244, localSQLException1);
      throw new DatabaseException(30031, this.jm244, localSQLException1, getId());
    }
    finally
    {
      log(this.jm244, l);
      try
      {
        if (localPreparedStatement != null)
          localPreparedStatement.close();
      }
      catch (SQLException localSQLException2)
      {
        jm249.error(localSQLException2);
        throw new DatabaseException(30023);
      }
    }
    return localVector1;
  }

  public Hashtable oneRowSelect(String paramString)
    throws DatabaseException
  {
    if (paramString == null)
      throw new DatabaseException(30042);
    Hashtable localHashtable = null;
    Statement localStatement = null;
    long l = (this.jm242) ? System.currentTimeMillis() : 0L;
    this.jm244 = paramString;
    try
    {
      localStatement = getConn().createStatement();
      ResultSet localResultSet = localStatement.executeQuery(paramString);
      ResultSetMetaData localResultSetMetaData = localResultSet.getMetaData();
      int i = localResultSetMetaData.getColumnCount();
      if (localResultSet.next())
      {
        int[] arrayOfInt = jm239(localResultSetMetaData, i);
        localHashtable = new Hashtable(i);
        for (int j = 0; j < i; ++j)
          localHashtable.put(localResultSetMetaData.getColumnName(j + 1).toLowerCase(), getValue(arrayOfInt[j], localResultSet, j + 1));
      }
      localResultSet.close();
    }
    catch (SQLException localSQLException1)
    {
      jm249.error(paramString, localSQLException1);
      throw new DatabaseException(30031, paramString, localSQLException1, getId());
    }
    finally
    {
      try
      {
        if (localStatement != null)
          localStatement.close();
      }
      catch (SQLException localSQLException2)
      {
        jm249.error(localSQLException2);
        throw new DatabaseException(30023);
      }
      log(paramString, l);
    }
    return localHashtable;
  }

  public Hashtable oneRowSelect(DBSQL paramDBSQL)
    throws DatabaseException
  {
    if (paramDBSQL == null)
      throw new DatabaseException(30042);
    Hashtable localHashtable = null;
    PreparedStatement localPreparedStatement = null;
    long l = (this.jm242) ? System.currentTimeMillis() : 0L;
    this.jm244 = paramDBSQL.toString();
    try
    {
      localPreparedStatement = getConn().prepareStatement(paramDBSQL.getSQL());
      paramDBSQL.toPreparedStatement(localPreparedStatement);
      ResultSet localResultSet = localPreparedStatement.executeQuery();
      ResultSetMetaData localResultSetMetaData = localResultSet.getMetaData();
      int i = localResultSetMetaData.getColumnCount();
      if (localResultSet.next())
      {
        int[] arrayOfInt = jm239(localResultSetMetaData, i);
        localHashtable = new Hashtable(i);
        for (int j = 0; j < i; ++j)
          localHashtable.put(localResultSetMetaData.getColumnName(j + 1).toLowerCase(), getValue(arrayOfInt[j], localResultSet, j + 1));
      }
      localResultSet.close();
    }
    catch (SQLException localSQLException1)
    {
      jm249.error(this.jm244, localSQLException1);
      throw new DatabaseException(30031, this.jm244, localSQLException1, getId());
    }
    finally
    {
      try
      {
        if (localPreparedStatement != null)
          localPreparedStatement.close();
      }
      catch (SQLException localSQLException2)
      {
        jm249.error(localSQLException2);
        throw new DatabaseException(30023);
      }
      log(this.jm244, l);
    }
    return localHashtable;
  }

  public Vector oneListSelect(String paramString, int paramInt)
    throws DatabaseException
  {
    if (paramString == null)
      throw new DatabaseException(30042);
    Vector localVector = new Vector();
    Statement localStatement = null;
    long l = (this.jm242) ? System.currentTimeMillis() : 0L;
    this.jm244 = paramString;
    try
    {
      localStatement = getConn().createStatement();
      ResultSet localResultSet = localStatement.executeQuery(paramString);
      int[] arrayOfInt = jm239(localResultSet.getMetaData(), 1);
      if (paramInt > 0)
        for (int i = 0; i < paramInt; ++i)
        {
          if (!(localResultSet.next()))
            break ;
          localVector.add(getValue(arrayOfInt[0], localResultSet, 1));
        }
      else
        while (localResultSet.next())
          localVector.add(getValue(arrayOfInt[0], localResultSet, 1));
      label160: localResultSet.close();
    }
    catch (SQLException localSQLException1)
    {
      jm249.error(paramString, localSQLException1);
      throw new DatabaseException(30031, paramString, localSQLException1, getId());
    }
    finally
    {
      try
      {
        if (localStatement != null)
          localStatement.close();
      }
      catch (SQLException localSQLException2)
      {
        jm249.error(localSQLException2);
        throw new DatabaseException(30023);
      }
      log(paramString, l);
    }
    return localVector;
  }

  public Vector oneListSelect(DBSQL paramDBSQL, int paramInt)
    throws DatabaseException
  {
    if (paramDBSQL == null)
      throw new DatabaseException(30042);
    Vector localVector = new Vector();
    PreparedStatement localPreparedStatement = null;
    long l = (this.jm242) ? System.currentTimeMillis() : 0L;
    this.jm244 = paramDBSQL.toString();
    try
    {
      localPreparedStatement = getConn().prepareStatement(paramDBSQL.getSQL());
      paramDBSQL.toPreparedStatement(localPreparedStatement);
      ResultSet localResultSet = localPreparedStatement.executeQuery();
      int[] arrayOfInt = jm239(localResultSet.getMetaData(), 1);
      if (paramInt > 0)
        for (int i = 0; i < paramInt; ++i)
        {
          if (!(localResultSet.next()))
            break ;
          localVector.add(getValue(arrayOfInt[0], localResultSet, 1));
        }
      else
        while (localResultSet.next())
          localVector.add(getValue(arrayOfInt[0], localResultSet, 1));
      label172: localResultSet.close();
    }
    catch (SQLException localSQLException1)
    {
      jm249.error(this.jm244, localSQLException1);
      throw new DatabaseException(30031, this.jm244, localSQLException1, getId());
    }
    finally
    {
      try
      {
        if (localPreparedStatement != null)
          localPreparedStatement.close();
      }
      catch (SQLException localSQLException2)
      {
        jm249.error(localSQLException2);
        throw new DatabaseException(30023);
      }
      log(this.jm244, l);
    }
    return localVector;
  }

  public int intSelect(String paramString)
    throws DatabaseException
  {
    if (paramString == null)
      throw new DatabaseException(30042);
    Statement localStatement = null;
    long l = (this.jm242) ? System.currentTimeMillis() : 0L;
    this.jm244 = paramString;
    int i = 0;
    try
    {
      localStatement = getConn().createStatement();
      ResultSet localResultSet = localStatement.executeQuery(paramString);
      if (localResultSet.next())
        i = localResultSet.getInt(1);
      localResultSet.close();
    }
    catch (SQLException localSQLException1)
    {
      jm249.error(paramString, localSQLException1);
      throw new DatabaseException(30031, paramString, localSQLException1, getId());
    }
    finally
    {
      try
      {
        if (localStatement != null)
          localStatement.close();
      }
      catch (SQLException localSQLException2)
      {
        jm249.error(localSQLException2);
        throw new DatabaseException(30023);
      }
      log(paramString, l);
    }
    return i;
  }

  public int intSelect(DBSQL paramDBSQL)
    throws DatabaseException
  {
    if (paramDBSQL == null)
      throw new DatabaseException(30042);
    PreparedStatement localPreparedStatement = null;
    long l = (this.jm242) ? System.currentTimeMillis() : 0L;
    this.jm244 = paramDBSQL.toString();
    int i = 0;
    try
    {
      localPreparedStatement = getConn().prepareStatement(paramDBSQL.getSQL());
      paramDBSQL.toPreparedStatement(localPreparedStatement);
      ResultSet localResultSet = localPreparedStatement.executeQuery();
      if (localResultSet.next())
        i = localResultSet.getInt(1);
      localResultSet.close();
    }
    catch (SQLException localSQLException1)
    {
      jm249.error(this.jm244, localSQLException1);
      throw new DatabaseException(30031, this.jm244, localSQLException1, getId());
    }
    finally
    {
      try
      {
        if (localPreparedStatement != null)
          localPreparedStatement.close();
      }
      catch (SQLException localSQLException2)
      {
        jm249.error(localSQLException2);
        throw new DatabaseException(30023);
      }
      log(this.jm244, l);
    }
    return i;
  }

  public String strSelect(String paramString)
    throws DatabaseException
  {
    if (paramString == null)
      throw new DatabaseException(30042);
    Statement localStatement = null;
    long l = (this.jm242) ? System.currentTimeMillis() : 0L;
    this.jm244 = paramString;
    String str = null;
    try
    {
      localStatement = getConn().createStatement();
      ResultSet localResultSet = localStatement.executeQuery(paramString);
      if (localResultSet.next())
        str = localResultSet.getString(1);
      localResultSet.close();
    }
    catch (SQLException localSQLException1)
    {
      jm249.error(paramString, localSQLException1);
      throw new DatabaseException(30031, paramString, localSQLException1, getId());
    }
    finally
    {
      try
      {
        if (localStatement != null)
          localStatement.close();
      }
      catch (SQLException localSQLException2)
      {
        jm249.error(localSQLException2);
        throw new DatabaseException(30023);
      }
      log(paramString, l);
    }
    return str;
  }

  public String strSelect(DBSQL paramDBSQL)
    throws DatabaseException
  {
    if (paramDBSQL == null)
      throw new DatabaseException(30042);
    PreparedStatement localPreparedStatement = null;
    long l = (this.jm242) ? System.currentTimeMillis() : 0L;
    this.jm244 = paramDBSQL.toString();
    String str = null;
    try
    {
      localPreparedStatement = getConn().prepareStatement(paramDBSQL.getSQL());
      paramDBSQL.toPreparedStatement(localPreparedStatement);
      ResultSet localResultSet = localPreparedStatement.executeQuery();
      if (localResultSet.next())
        str = localResultSet.getString(1);
      localResultSet.close();
    }
    catch (SQLException localSQLException1)
    {
      jm249.error(this.jm244, localSQLException1);
      throw new DatabaseException(30031, this.jm244, localSQLException1, getId());
    }
    finally
    {
      try
      {
        if (localPreparedStatement != null)
          localPreparedStatement.close();
      }
      catch (SQLException localSQLException2)
      {
        jm249.error(localSQLException2);
        throw new DatabaseException(30023);
      }
      log(this.jm244, l);
    }
    return str;
  }

  public int execute(String paramString)
    throws DatabaseException
  {
    long l = (this.jm242) ? System.currentTimeMillis() : 0L;
    this.jm244 = paramString;
    if (paramString == null)
      throw new DatabaseException(30042);
    Statement localStatement = null;
    try
    {
      localStatement = getConn().createStatement();
      int i = localStatement.executeUpdate(paramString);
      return i;
    }
    catch (SQLException localSQLException1)
    {
      jm249.error(paramString, localSQLException1);
      throw new DatabaseException(30031, paramString, localSQLException1, getId());
    }
    finally
    {
      try
      {
        if (localStatement != null)
          localStatement.close();
      }
      catch (SQLException localSQLException2)
      {
        jm249.error(localSQLException2);
        throw new DatabaseException(30023);
      }
      log(paramString, l);
    }
  }

  public int execute(DBSQL paramDBSQL)
    throws DatabaseException
  {
    long l = (this.jm242) ? System.currentTimeMillis() : 0L;
    this.jm244 = paramDBSQL.toString();
    if (paramDBSQL == null)
      throw new DatabaseException(30042);
    PreparedStatement localPreparedStatement = null;
    try
    {
      localPreparedStatement = getConn().prepareStatement(paramDBSQL.getSQL());
      paramDBSQL.toPreparedStatement(localPreparedStatement);
      int i = localPreparedStatement.executeUpdate();
      return i;
    }
    catch (SQLException localSQLException1)
    {
      jm249.error(this.jm244, localSQLException1);
      throw new DatabaseException(30031, this.jm244, localSQLException1, getId());
    }
    finally
    {
      try
      {
        if (localPreparedStatement != null)
          localPreparedStatement.close();
      }
      catch (SQLException localSQLException2)
      {
        jm249.error(localSQLException2);
        throw new DatabaseException(30023);
      }
      log(this.jm244, l);
    }
  }

  protected BizObjFields getTableFields(String paramString)
    throws DatabaseException
  {
    if ((paramString == null) || (paramString.equals("")))
      throw new DatabaseException(30047);
    long l = (this.jm242) ? System.currentTimeMillis() : 0L;
    String str1 = "SELECT * FROM " + paramString + " WHERE 1=0";
    this.jm244 = str1;
    BizObjFields localBizObjFields = new BizObjFields();
    Statement localStatement = null;
    try
    {
      localStatement = getConn().createStatement();
      ResultSet localResultSet = localStatement.executeQuery(str1);
      ResultSetMetaData localResultSetMetaData = localResultSet.getMetaData();
      int i = localResultSetMetaData.getColumnCount();
      for (int j = 1; j <= i; ++j)
      {
        String str2 = localResultSetMetaData.getColumnName(j).toLowerCase();
        localBizObjFields.put(str2, localResultSetMetaData.getColumnType(j));
      }
      localResultSet.close();
    }
    catch (SQLException localSQLException1)
    {
      jm249.error(localSQLException1);
      throw new DatabaseException(30031, str1, localSQLException1);
    }
    finally
    {
      try
      {
        if (localStatement != null)
          localStatement.close();
      }
      catch (SQLException localSQLException2)
      {
        jm249.error(localSQLException2);
        throw new DatabaseException(30023);
      }
      log(str1, l);
    }
    return localBizObjFields;
  }

  public Vector getCall(String paramString, List paramList, int paramInt)
    throws DatabaseException
  {
    long l = (this.jm242) ? System.currentTimeMillis() : 0L;
    String str1 = "";
    CallableStatement localCallableStatement = null;
    try
    {
      Object localObject1 = null;
      Vector localVector = new Vector();
      int i;
      int j;
      String str3;
      if (getDBType() == 1)
      {
        if (paramInt == 1)
        {
          str1 = "begin :1:=" + paramString + "(";
          localVector.add("?");
        }
        else if (paramInt == 2)
        {
          str1 = "begin :1:=" + paramString + "(";
          localVector.add("?CURSOR");
        }
        else
        {
          str1 = "begin " + paramString + "(";
        }
        if ((paramList != null) && (paramList.size() > 0))
        {
          i = 1;
          for (j = 0; j < paramList.size(); ++j)
          {
            str3 = (String)paramList.get(j);
            if ((str3 == null) || (str3.length() <= 0))
              continue;
            str3 = str3.trim();
            if (i == 0)
              str1 = str1 + ",";
            else
              i = 0;
            if (str3.equals("?"))
            {
              str1 = str1 + ":" + String.valueOf(localVector.size() + 1);
              localVector.add(str3);
            }
            else if (str3.compareToIgnoreCase("?CURSOR") == 0)
            {
              str1 = str1 + ":" + String.valueOf(localVector.size() + 1);
              localVector.add(str3);
            }
            else
            {
              str1 = str1 + str3;
            }
          }
        }
        str1 = str1 + "); end;";
      }
      else
      {
        if (paramInt == 1)
        {
          str1 = "?= call " + paramString + "(";
          localVector.add("?");
        }
        else if ((paramInt == 2) && (getDBType() != 2) && (getDBType() != 4))
        {
          str1 = "call ?=" + paramString + "(";
          localVector.add("?CURSOR");
        }
        else
        {
          str1 = "call " + paramString + "(";
        }
        if ((paramList != null) && (paramList.size() > 0))
        {
          i = 1;
          for (j = 0; j < paramList.size(); ++j)
          {
            str3 = (String)paramList.get(j);
            if ((str3 == null) || (str3.length() <= 0))
              continue;
            str3 = str3.trim();
            if (i == 0)
              str1 = str1 + ",";
            else
              i = 0;
            if (str3.equals("?"))
            {
              str1 = str1 + "?";
              localVector.add(str3);
            }
            else if (str3.compareToIgnoreCase("?CURSOR") == 0)
            {
              str1 = str1 + "?";
              localVector.add(str3);
            }
            else
            {
              str1 = str1 + str3;
            }
          }
        }
        str1 = "{" + str1 + ")}";
      }
      this.jm244 = str1;
      localCallableStatement = getConn().prepareCall(str1);
      String str2;
      if ((localVector != null) && (localVector.size() > 0))
        for (i = 0; i < localVector.size(); ++i)
        {
          str2 = (String)localVector.elementAt(i);
          if (str2.equals("?"))
          {
            localCallableStatement.registerOutParameter(i + 1, 12);
          }
          else
          {
            if (str2.compareToIgnoreCase("?CURSOR") != 0)
              continue;
            if (getDBType() == 1)
              localCallableStatement.registerOutParameter(i + 1, -10);
            else
              localCallableStatement.registerOutParameter(i + 1, 1111);
          }
        }
      localCallableStatement.execute();
      Object localObject2;
      if ((localVector != null) && (localVector.size() > 0))
      {
        for (i = 0; i < localVector.size(); ++i)
        {
          str2 = (String)localVector.elementAt(i);
          if (str2.compareToIgnoreCase("?CURSOR") == 0)
          {
            localObject1 = (ResultSet)localCallableStatement.getObject(i + 1);
          }
          else
          {
            str3 = localCallableStatement.getString(i + 1);
            if (str3 == null)
              str3 = "";
            localVector.set(i, str3);
          }
        }
      }
      else if ((getDBType() == 2) || (4 == getDBType()))
      {
        localObject2 = localCallableStatement.getResultSet();
        for (int k = 5000; (k > 0) && (localObject2 == null) && (localCallableStatement.getUpdateCount() != -1); --k)
          try
          {
            if (localCallableStatement.getMoreResults())
              localObject2 = localCallableStatement.getResultSet();
          }
          catch (Exception localException1)
          {
          }
        localObject1 = localObject2;
      }
      Object localObject5;
      if (localObject1 != null)
      {
        localObject2 = new Vector();
        ResultSetMetaData localResultSetMetaData = ((ResultSet)localObject1).getMetaData();
        int i1 = localResultSetMetaData.getColumnCount();
        int i2 = ServerConfig.QueryLimit / i1;
        String[] arrayOfString = new String[i1];
        for (int i3 = 0; i3 < i1; ++i3)
          arrayOfString[i3] = localResultSetMetaData.getColumnName(i3 + 1).toLowerCase();
        int[] arrayOfInt = jm239(localResultSetMetaData, i1);
        int i4 = 0;
        while (((ResultSet)localObject1).next())
        {
          Hashtable localHashtable = new Hashtable();
          for (int i5 = 0; i5 < i1; ++i5)
            localHashtable.put(arrayOfString[i5], getValue(arrayOfInt[i5], (ResultSet)localObject1, i5 + 1));
          ((Vector)localObject2).add(localHashtable);
          if (++i4 <= i2)
            continue;
          throw new DatabaseException(30002);
        }
        ((ResultSet)localObject1).close();
        localObject5 = localObject2;
        return (Vector)localObject5;
      }
      if ((2 != paramInt) && (localVector != null) && (localVector.size() > 0))
      {
        localObject5 = localVector;
        return (Vector)localObject5;
      }
      return null;
    }
    catch (SQLException localSQLException)
    {
      jm249.error(str1, localSQLException);
      throw new DatabaseException(30031, str1, localSQLException, getId());
    }
    finally
    {
      if (localCallableStatement != null)
        try
        {
          localCallableStatement.close();
        }
        catch (Exception localException2)
        {
        }
      log(str1, l);
    }
  }

  public Vector[] getCall2(String paramString, Collection paramCollection, int paramInt)
    throws DatabaseException
  {
    long l = (this.jm242) ? System.currentTimeMillis() : 0L;
    String str1 = "";
    CallableStatement localCallableStatement = null;
    try
    {
      ResultSet localResultSet = null;
      Vector localVector1 = new Vector();
      Vector localVector2 = null;
      if (paramCollection != null)
        localVector2 = new Vector(paramCollection);
      Vector localVector3 = new Vector();
      int i;
      int j;
      String str3;
      if (getDBType() == 1)
      {
        if (paramInt == 1)
        {
          str1 = "begin :1:=" + paramString + "(";
          localVector3.add("?");
        }
        else if (paramInt == 2)
        {
          str1 = "begin :1:=" + paramString + "(";
          localVector3.add("?CURSOR");
        }
        else
        {
          str1 = "begin " + paramString + "(";
        }
        if ((localVector2 != null) && (localVector2.size() > 0))
        {
          i = 1;
          for (j = 0; j < localVector2.size(); ++j)
          {
            str3 = (String)localVector2.get(j);
            if ((str3 == null) || (str3.length() <= 0))
              continue;
            str3 = str3.trim();
            if (i == 0)
              str1 = str1 + ",";
            else
              i = 0;
            if (str3.equals("?"))
            {
              str1 = str1 + ":" + String.valueOf(localVector3.size() + 1);
              localVector3.add(str3);
            }
            else if (str3.compareToIgnoreCase("?CURSOR") == 0)
            {
              str1 = str1 + ":" + String.valueOf(localVector3.size() + 1);
              localVector3.add(str3);
            }
            else
            {
              str1 = str1 + str3;
            }
          }
        }
        str1 = str1 + "); end;";
      }
      else
      {
        if (paramInt == 1)
        {
          str1 = "?= call " + paramString + "(";
          localVector3.add("?");
        }
        else if ((paramInt == 2) && (getDBType() != 2) && (getDBType() != 4))
        {
          str1 = "call ?=" + paramString + "(";
          localVector3.add("?CURSOR");
        }
        else
        {
          str1 = "call " + paramString + "(";
        }
        if ((localVector2 != null) && (localVector2.size() > 0))
        {
          i = 1;
          for (j = 0; j < localVector2.size(); ++j)
          {
            str3 = (String)localVector2.get(j);
            if ((str3 == null) || (str3.length() <= 0))
              continue;
            str3 = str3.trim();
            if (i == 0)
              str1 = str1 + ",";
            else
              i = 0;
            if (str3.equals("?"))
            {
              str1 = str1 + "?";
              localVector3.add(str3);
            }
            else if (str3.compareToIgnoreCase("?CURSOR") == 0)
            {
              str1 = str1 + "?";
              localVector3.add(str3);
            }
            else
            {
              str1 = str1 + str3;
            }
          }
        }
        str1 = "{" + str1 + ")}";
      }
      this.jm244 = str1;
      localCallableStatement = getConn().prepareCall(str1);
      String str2;
      if ((localVector3 != null) && (localVector3.size() > 0))
        for (i = 0; i < localVector3.size(); ++i)
        {
          str2 = (String)localVector3.elementAt(i);
          if (str2.equals("?"))
          {
            localCallableStatement.registerOutParameter(i + 1, 12);
          }
          else
          {
            if (str2.compareToIgnoreCase("?CURSOR") != 0)
              continue;
            if (getDBType() == 1)
              localCallableStatement.registerOutParameter(i + 1, -10);
            else
              localCallableStatement.registerOutParameter(i + 1, 1111);
          }
        }
      localCallableStatement.execute();
      if ((localVector3 != null) && (localVector3.size() > 0))
      {
        for (i = 0; i < localVector3.size(); ++i)
        {
          str2 = (String)localVector3.elementAt(i);
          if (str2.equals("?"))
          {
            str3 = (String)localCallableStatement.getObject(i + 1);
            if (str3 == null)
              str3 = "";
            localVector1.add(str3);
          }
          else
          {
            if (str2.compareToIgnoreCase("?CURSOR") != 0)
              continue;
            localResultSet = (ResultSet)localCallableStatement.getObject(i + 1);
          }
        }
      }
      else if ((getDBType() == 2) || (4 == getDBType()))
      {
        localResultSet = localCallableStatement.getResultSet();
        for (i = 5000; (i > 0) && (localResultSet == null) && (localCallableStatement.getUpdateCount() != -1); --i)
          try
          {
            if (localCallableStatement.getMoreResults())
              localResultSet = localCallableStatement.getResultSet();
          }
          catch (Exception localException1)
          {
            jm249.error(localException1);
          }
        if (localResultSet == null)
          localVector1.add(String.valueOf(localCallableStatement.getUpdateCount()));
      }
      if (localResultSet != null)
      {
    	  Vector[]   arrayOfVector1 = jm240(localResultSet, 0);
        localResultSet.close();
     // arrayOfVector1;
        return arrayOfVector1;
      }
      Vector[] arrayOfVector1 = new Vector[2];
      arrayOfVector1[0] = new Vector(1);
      arrayOfVector1[1] = new Vector(1);
      Vector localVector4 = new Vector();
      localVector4.add("Field1");
      localVector4.add("string");
      localVector4.add("250");
      localVector4.add("0");
      arrayOfVector1[0].add(localVector4);
      if (localVector1.size() < 1)
        localVector1.add("");
      arrayOfVector1[1].add(localVector1);
      Vector[] arrayOfVector2 = arrayOfVector1;
      return arrayOfVector2;
    }
    catch (SQLException localSQLException)
    {
      jm249.error(str1, localSQLException);
      throw new DatabaseException(30031, str1, localSQLException, getId());
    }
    finally
    {
      if (localCallableStatement != null)
        try
        {
          localCallableStatement.close();
        }
        catch (Exception localException2)
        {
        }
      log(str1, l);
    }
  }

  public PreparedStatement getPrepareStatement(String paramString)
    throws DatabaseException
  {
    long l = (this.jm242) ? System.currentTimeMillis() : 0L;
    this.jm244 = paramString;
    try
    {
      PreparedStatement localPreparedStatement = getConn().prepareStatement(paramString);
      return localPreparedStatement;
    }
    catch (SQLException localSQLException)
    {
      jm249.error(paramString, localSQLException);
      throw new DatabaseException(30031, paramString, localSQLException, getId());
    }
    finally
    {
      log(paramString, l);
    }
  }

  public CallableStatement getCallableStatement(String paramString)
    throws DatabaseException
  {
    long l = (this.jm242) ? System.currentTimeMillis() : 0L;
    this.jm244 = paramString;
    try
    {
      CallableStatement localCallableStatement = getConn().prepareCall(paramString);
      return localCallableStatement;
    }
    catch (SQLException localSQLException)
    {
      jm249.error(paramString, localSQLException);
      throw new DatabaseException(30031, paramString, localSQLException, getId());
    }
    finally
    {
      log(paramString, l);
    }
  }

  public Vector[] multiRowSelect2(String paramString, int paramInt)
    throws DatabaseException
  {
    if (paramString == null)
      return null;
    Statement localStatement = null;
    long l = (this.jm242) ? System.currentTimeMillis() : 0L;
    this.jm244 = paramString;
    try
    {
      localStatement = getConn().createStatement();
      ResultSet localResultSet = localStatement.executeQuery(paramString);
      Vector[] arrayOfVector1 = jm240(localResultSet, paramInt);
      localResultSet.close();
      Vector[] arrayOfVector2 = arrayOfVector1;
      return arrayOfVector2;
    }
    catch (SQLException localSQLException1)
    {
      jm249.error(paramString, localSQLException1);
      throw new DatabaseException(30031, paramString, localSQLException1, getId());
    }
    finally
    {
      log(paramString, l);
      try
      {
        if (localStatement != null)
          localStatement.close();
      }
      catch (SQLException localSQLException2)
      {
        jm249.error(localSQLException2);
        throw new DatabaseException(30023);
      }
    }
  }

  public Vector[] multiRowSelect2(DBSQL paramDBSQL, int paramInt)
    throws DatabaseException
  {
    if (paramDBSQL == null)
      return null;
    PreparedStatement localPreparedStatement = null;
    long l = (this.jm242) ? System.currentTimeMillis() : 0L;
    this.jm244 = paramDBSQL.toString();
    try
    {
      localPreparedStatement = getConn().prepareStatement(paramDBSQL.getSQL());
      paramDBSQL.toPreparedStatement(localPreparedStatement);
      ResultSet localResultSet = localPreparedStatement.executeQuery();
      Vector[] arrayOfVector1 = jm240(localResultSet, paramInt);
      localResultSet.close();
      Vector[] arrayOfVector2 = arrayOfVector1;
      return arrayOfVector2;
    }
    catch (SQLException localSQLException1)
    {
      jm249.error(this.jm244, localSQLException1);
      throw new DatabaseException(30031, this.jm244, localSQLException1, getId());
    }
    finally
    {
      log(this.jm244, l);
      try
      {
        if (localPreparedStatement != null)
          localPreparedStatement.close();
      }
      catch (SQLException localSQLException2)
      {
        jm249.error(localSQLException2);
        throw new DatabaseException(30023);
      }
    }
  }

  private Vector[] jm240(ResultSet paramResultSet, int paramInt)
    throws DatabaseException, SQLException
  {
    ResultSetMetaData localResultSetMetaData = paramResultSet.getMetaData();
    int i = localResultSetMetaData.getColumnCount();
    if (i < 1)
      return null;
    Vector localVector1 = new Vector(i);
    Vector localVector2 = new Vector();
    int j = ServerConfig.QueryLimit / i;
    int i3;
    try
    {
      for (int k = 1; k <= i; ++k)
      {
        Vector localVector3 = new Vector();
        localVector3.add(localResultSetMetaData.getColumnName(k));
        int i2 = localResultSetMetaData.getColumnType(k);
        i3 = localResultSetMetaData.getColumnDisplaySize(k);
        int i4 = localResultSetMetaData.getScale(k);
        switch (i2)
        {
        case 1:
          localVector3.add("string");
          if (i3 < 1)
            i3 = 1;
          break;
        case 2:
          localVector3.add("r8");
          break;
        case 3:
          localVector3.add("r8");
          break;
        case 4:
          localVector3.add("i4");
          break;
        case 5:
          localVector3.add("i4");
          break;
        case 6:
          localVector3.add("r8");
          break;
        case 7:
          localVector3.add("r8");
          break;
        case 8:
          localVector3.add("r8");
          break;
        case 12:
          localVector3.add("string");
          if (i3 < 1)
            i3 = 1;
          break;
        case 91:
          localVector3.add("datetime");
          i4 = 91;
          break;
        case 92:
          localVector3.add("datetime");
          i4 = 92;
          break;
        case 93:
          localVector3.add("datetime");
          i4 = 93;
          break;
        case -1:
          localVector3.add("string");
          if (i3 < 1)
            i3 = 1;
          break;
        case -5:
          localVector3.add("i4");
          break;
        case -6:
          localVector3.add("i4");
          break;
        case -7:
          localVector3.add("i4");
          break;
        default:
          localVector3.add("string");
        }
        localVector3.add(String.valueOf(i3));
        localVector3.add(String.valueOf(i4));
        localVector1.add(localVector3);
      }
    }
    catch (SQLException localSQLException)
    {
      jm249.error(localSQLException);
      throw new DatabaseException(localSQLException.getMessage());
    }
    int[] arrayOfInt = jm239(localResultSetMetaData, i);
    Vector localVector4;
    if (paramInt > 0)
    {
      int l = 0;
  
      do
      {
        localVector4 = new Vector();
        for (i3 = 0; i3 < i; ++i3)
          localVector4.add(getValue(arrayOfInt[i3], paramResultSet, i3 + 1));
        localVector2.add(localVector4);
        if (l >= j)
          throw new DatabaseException(30002);
        ++l;
        label653: if (l >= paramInt){
        	 Vector[] arrayOfVector = new Vector[2];
        arrayOfVector[0] = localVector1;
        arrayOfVector[1] = localVector2;
        return arrayOfVector;}
      }
      while (paramResultSet.next());
    }
    else
    {
      int i1 = 0;
      while (paramResultSet.next())
      {
        localVector4 = new Vector();
        for (i3 = 0; i3 < i; ++i3)
          localVector4.add(getValue(arrayOfInt[i3], paramResultSet, i3 + 1));
        localVector2.add(localVector4);
        if (++i1 <= j)
          continue;
        throw new DatabaseException(30002);
      }
    }
    Vector[] arrayOfVector = new Vector[2];
    arrayOfVector[0] = localVector1;
    arrayOfVector[1] = localVector2;
    return arrayOfVector;
  }

  public int getDBType()
  {
    return this.jm247;
  }

  public boolean isConnected()
  {
    return (this.jm243 != null);
  }

  public int IDGenerator(DBControl paramDBControl, String paramString1, String paramString2, boolean paramBoolean)
    throws DatabaseException
  {
    StringBuffer localStringBuffer = new StringBuffer(128);
    PreparedStatement localPreparedStatement = null;
    int i = 0;
    String str = null;
    long l = (this.jm242) ? System.currentTimeMillis() : 0L;
    try
    {
      if (paramBoolean)
        localStringBuffer.append("UPDATE cpcidlist SET keyid=keyid-1");
      else
        localStringBuffer.append("UPDATE cpcidlist SET keyid=keyid+1");
      localStringBuffer.append(" WHERE keyname=?");
      str = localStringBuffer.toString();
      localPreparedStatement = getConn().prepareStatement(str);
      if (paramBoolean)
        localPreparedStatement.setString(1, "-" + paramString1);
      else
        localPreparedStatement.setString(1, paramString1);
      int j = localPreparedStatement.executeUpdate();
      log(str, l);
      l = (this.jm242) ? System.currentTimeMillis() : 0L;
      ResultSet localResultSet;
      if (j <= 0)
      {
        localStringBuffer.delete(0, localStringBuffer.length());
        if (paramBoolean)
        {
          localStringBuffer.append("SELECT min(");
          localStringBuffer.append(paramString2);
          localStringBuffer.append(") FROM ");
          localStringBuffer.append(paramString1);
          localStringBuffer.append(" WHERE ");
          localStringBuffer.append(paramString2);
          localStringBuffer.append("<0");
        }
        else
        {
          localStringBuffer.append("SELECT max(");
          localStringBuffer.append(paramString2);
          localStringBuffer.append(") FROM ");
          localStringBuffer.append(paramString1);
          localStringBuffer.append(" WHERE ");
          localStringBuffer.append(paramString2);
          localStringBuffer.append(">0");
        }
        str = localStringBuffer.toString();
        if (paramDBControl != null)
        {
          i = paramDBControl.intSelect(str);
        }
        else
        {
          this.jm244 = str;
          localResultSet = localPreparedStatement.executeQuery(str);
          if (localResultSet.next())
            i = localResultSet.getInt(1);
          localResultSet.close();
        }
        if (paramBoolean)
          if (i > -1001)
            i = -1001;
          else
            --i;
        else if (i <= 0)
          i = 1;
        else
          ++i;
        localPreparedStatement.close();
        localPreparedStatement = null;
        str = "INSERT INTO cpcidlist  values(?,?)";
        this.jm244 = str;
        localPreparedStatement = getConn().prepareStatement(str);
        if (paramBoolean)
          localPreparedStatement.setString(1, "-" + paramString1);
        else
          localPreparedStatement.setString(1, paramString1);
        localPreparedStatement.setInt(2, i);
        localPreparedStatement.executeUpdate();
        localPreparedStatement.close();
      }
      else
      {
        localPreparedStatement.close();
        localPreparedStatement = null;
        str = "SELECT keyid FROM cpcidlist WHERE keyname=?";
        this.jm244 = str;
        localPreparedStatement = getConn().prepareStatement(str);
        if (paramBoolean)
          localPreparedStatement.setString(1, "-" + paramString1);
        else
          localPreparedStatement.setString(1, paramString1);
        localResultSet = localPreparedStatement.executeQuery();
        if (localResultSet.next())
          i = localResultSet.getInt(1);
        localResultSet.close();
      }
      int k = i;
      return k;
    }
    catch (SQLException localSQLException1)
    {
      jm249.error(str, localSQLException1);
      throw new DatabaseException(30031, str, localSQLException1, getId());
    }
    finally
    {
      try
      {
        if (localPreparedStatement != null)
          localPreparedStatement.close();
      }
      catch (SQLException localSQLException2)
      {
        jm249.error(localSQLException2);
        throw new DatabaseException(30023);
      }
      log(str, l);
    }
  }

  public synchronized int IDGenerator(String paramString1, String paramString2, String paramString3)
    throws DatabaseException
  {
    if ((paramString1 == null) || (paramString2 == null) || (paramString1.length() < 1) || (paramString2.length() < 1))
      throw new DatabaseException(30042);
    long l = (this.jm242) ? System.currentTimeMillis() : 0L;
    int i = 0;
    Statement localStatement = null;
    String str1 = "";
    str1 = paramString3.trim().toLowerCase();
    if (!(str1.startsWith("where ")))
      str1 = "WHERE " + paramString3.trim();
    else
      str1 = paramString3.trim();
    StringBuffer localStringBuffer = new StringBuffer(128);
    localStringBuffer.append("SELECT MAX(");
    localStringBuffer.append(paramString2);
    localStringBuffer.append(") FROM ");
    localStringBuffer.append(paramString1);
    localStringBuffer.append(" ");
    localStringBuffer.append(str1);
    String str2 = localStringBuffer.toString();
    try
    {
      this.jm244 = str2;
      localStatement = getConn().createStatement();
      ResultSet localResultSet = localStatement.executeQuery(str2);
      if (localResultSet.next())
        i = localResultSet.getInt(1);
      localResultSet.close();
    }
    catch (SQLException localSQLException1)
    {
      jm249.error(str2, localSQLException1);
      throw new DatabaseException(30031, str2, localSQLException1, getId());
    }
    finally
    {
      try
      {
        if (localStatement != null)
          localStatement.close();
      }
      catch (SQLException localSQLException2)
      {
        jm249.error(localSQLException2);
        throw new DatabaseException(30023);
      }
      log(str2, l);
    }
    return (i + 1);
  }

  public ResultSet getResultSet(String paramString)
    throws DatabaseException
  {
    if (paramString == null)
      throw new DatabaseException(30042);
    Statement localStatement = null;
    long l = (this.jm242) ? System.currentTimeMillis() : 0L;
    this.jm244 = paramString;
    try
    {
      localStatement = getConn().createStatement();
      ResultSet localResultSet = localStatement.executeQuery(paramString);
      return localResultSet;
    }
    catch (SQLException localSQLException)
    {
      if (localStatement != null)
        try
        {
          localStatement.close();
        }
        catch (Exception localException)
        {
        }
      jm249.error(paramString, localSQLException);
      throw new DatabaseException(30031, paramString, localSQLException, getId());
    }
    finally
    {
      log(paramString, l);
    }
  }

  public Hashtable getColumnTypes(String paramString)
    throws DatabaseException
  {
    if ((paramString == null) || (paramString.equals("")))
      throw new DatabaseException(30047);
    long l = (ServerConfig.IsLogSQLCost) ? System.currentTimeMillis() : 0L;
    String str1 = "SELECT * FROM " + paramString + " WHERE 1=0";
    this.jm244 = str1;
    Hashtable localHashtable = new Hashtable();
    Statement localStatement = null;
    try
    {
      localStatement = getConn().createStatement();
      ResultSet localResultSet = localStatement.executeQuery(str1);
      ResultSetMetaData localResultSetMetaData = localResultSet.getMetaData();
      int i = localResultSetMetaData.getColumnCount();
      for (int j = 1; j <= i; ++j)
      {
        String str2 = localResultSetMetaData.getColumnName(j).toLowerCase();
        localHashtable.put(str2, String.valueOf(localResultSetMetaData.getColumnType(j)));
      }
    }
    catch (SQLException localSQLException1)
    {
      localSQLException1.printStackTrace();
      throw new DatabaseException(30031, str1, localSQLException1, getId());
    }
    finally
    {
      try
      {
        localStatement.close();
      }
      catch (SQLException localSQLException2)
      {
        jm249.error(localSQLException2);
        throw new DatabaseException(30023);
      }
      log(str1, l);
    }
    return localHashtable;
  }

  public Vector selectObjectData(String paramString)
    throws DatabaseException
  {
    if (paramString == null)
      throw new DatabaseException(30042);
    Vector localVector1 = new Vector();
    Statement localStatement = null;
    long l = (this.jm242) ? System.currentTimeMillis() : 0L;
    this.jm244 = paramString;
    try
    {
      localStatement = getConn().createStatement();
      ResultSet localResultSet = localStatement.executeQuery(paramString);
      ResultSetMetaData localResultSetMetaData = localResultSet.getMetaData();
      int i = localResultSetMetaData.getColumnCount();
      while (localResultSet.next())
      {
        Vector localVector2 = new Vector();
        for (int j = 1; j <= i; ++j)
          localVector2.addElement(localResultSet.getObject(j));
        localVector1.add(localVector2);
      }
    }
    catch (SQLException localSQLException1)
    {
      jm249.error(paramString, localSQLException1);
      throw new DatabaseException(30031, paramString, localSQLException1, getId());
    }
    finally
    {
      try
      {
        if (localStatement != null)
          localStatement.close();
      }
      catch (SQLException localSQLException2)
      {
        jm249.error(localSQLException2);
        throw new DatabaseException(30023);
      }
      log(paramString, l);
    }
    return localVector1;
  }

  public Vector selectObjectData(DBSQL paramDBSQL)
    throws DatabaseException
  {
    if (paramDBSQL == null)
      throw new DatabaseException(30042);
    Vector localVector1 = new Vector();
    PreparedStatement localPreparedStatement = null;
    long l = (this.jm242) ? System.currentTimeMillis() : 0L;
    this.jm244 = paramDBSQL.toString();
    try
    {
      localPreparedStatement = getConn().prepareStatement(paramDBSQL.getSQL());
      paramDBSQL.toPreparedStatement(localPreparedStatement);
      ResultSet localResultSet = localPreparedStatement.executeQuery();
      ResultSetMetaData localResultSetMetaData = localResultSet.getMetaData();
      int i = localResultSetMetaData.getColumnCount();
      while (localResultSet.next())
      {
        Vector localVector2 = new Vector();
        for (int j = 1; j <= i; ++j)
          localVector2.addElement(localResultSet.getObject(j));
        localVector1.add(localVector2);
      }
    }
    catch (SQLException localSQLException1)
    {
      jm249.error(this.jm244, localSQLException1);
      throw new DatabaseException(30031, this.jm244, localSQLException1, getId());
    }
    finally
    {
      try
      {
        if (localPreparedStatement != null)
          localPreparedStatement.close();
      }
      catch (SQLException localSQLException2)
      {
        jm249.error(localSQLException2);
        throw new DatabaseException(30023);
      }
      log(this.jm244, l);
    }
    return localVector1;
  }

  public int streamSelect(DBSQL paramDBSQL, OutputStream paramOutputStream)
    throws DatabaseException
  {
    if (paramDBSQL == null)
      throw new DatabaseException(30042);
    PreparedStatement localPreparedStatement = null;
    long l = (this.jm242) ? System.currentTimeMillis() : 0L;
    this.jm244 = paramDBSQL.toString();
    int i = 0;
    try
    {
      localPreparedStatement = getConn().prepareStatement(paramDBSQL.getSQL());
      paramDBSQL.toPreparedStatement(localPreparedStatement);
      ResultSet localResultSet = localPreparedStatement.executeQuery();
      if (localResultSet.next())
      {
        InputStream localInputStream = localResultSet.getBinaryStream(1);
        if (localInputStream != null)
        {
          byte[] arrayOfByte = new byte[4096];
          int j = 0;
          while (true)
          {
            j = localInputStream.read(arrayOfByte);
            if (j < 0)
              break;
            if (j <= 0)
              continue;
            i += j;
            paramOutputStream.write(arrayOfByte, 0, j);
            paramOutputStream.flush();
          }
          localInputStream.close();
        }
      }
      localResultSet.close();
    }
    catch (SQLException localSQLException1)
    {
      jm249.error(this.jm244, localSQLException1);
      throw new DatabaseException(30031, this.jm244, localSQLException1, getId());
    }
    catch (IOException localIOException)
    {
      jm249.error(this.jm244, localIOException);
      throw new DatabaseException(30031, localIOException.getMessage());
    }
    finally
    {
      try
      {
        if (localPreparedStatement != null)
          localPreparedStatement.close();
      }
      catch (SQLException localSQLException2)
      {
        jm249.error(localSQLException2);
        throw new DatabaseException(30023);
      }
      log(this.jm244, l);
    }
    return i;
  }

  public int streamSelect(String paramString, OutputStream paramOutputStream)
    throws DatabaseException
  {
    if (paramString == null)
      throw new DatabaseException(30042);
    Statement localStatement = null;
    long l = (this.jm242) ? System.currentTimeMillis() : 0L;
    this.jm244 = paramString;
    int i = 0;
    try
    {
      localStatement = getConn().createStatement();
      ResultSet localResultSet = localStatement.executeQuery(paramString);
      if (localResultSet.next())
      {
        InputStream localInputStream = localResultSet.getBinaryStream(1);
        if (localInputStream != null)
        {
          byte[] arrayOfByte = new byte[4096];
          int j = 0;
          while (true)
          {
            j = localInputStream.read(arrayOfByte);
            if (j < 0)
              break;
            if (j <= 0)
              continue;
            i += j;
            paramOutputStream.write(arrayOfByte, 0, j);
            paramOutputStream.flush();
          }
          localInputStream.close();
        }
      }
      localResultSet.close();
    }
    catch (SQLException localSQLException1)
    {
      jm249.error(this.jm244, localSQLException1);
      throw new DatabaseException(30031, this.jm244, localSQLException1, getId());
    }
    catch (IOException localIOException)
    {
      jm249.error(this.jm244, localIOException);
      throw new DatabaseException(30031, localIOException.getMessage());
    }
    finally
    {
      try
      {
        if (localStatement != null)
          localStatement.close();
      }
      catch (SQLException localSQLException2)
      {
        jm249.error(localSQLException2);
        throw new DatabaseException(30023);
      }
      log(this.jm244, l);
    }
    return i;
  }

  public void freeConnection()
  {
    if (this.jm243 == null)
      return;
    this.jm243.close();
    this.jm243 = null;
  }

  public static void main(String[] paramArrayOfString)
  {
    long l = System.currentTimeMillis();
    l = System.currentTimeMillis();
    for (int i = 0; i < 10000; ++i)
    {
      double d = 1.3D + i;
      String.valueOf(d);
    }
    System.out.println("time1: " + (System.currentTimeMillis() - l));
  }
}